﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShevaEngine.Core.Interfaces;
using Microsoft.Xna.Framework;

namespace ShevaEngine2GUI
{
    /// <summary>
    /// Layer.
    /// </summary>
    public class Layer : Control, IUpdateAble
    {
        /// <summary>Mouse cursor.</summary>
        internal MouseCursor Cursor;
        /// <summary>Gui manager.</summary>
        public GuiManager GuiManager;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="size"></param>
        internal Layer(GuiManager manager)
        {
            this.GuiManager = manager;
            this.Cursor = null;

            this.LocationSize = new Rectangle(0, 0, (int)this.GuiManager.Size.X, (int)this.GuiManager.Size.Y);
            this.RealLocationSize = this.LocationSize;
        }

        /// <summary>
        /// Method redesing.
        /// </summary>        
        public override void Redesign()
        {
            this.LocationSize = new Rectangle(0, 0, (int)this.GuiManager.Size.X, (int)this.GuiManager.Size.Y);
            this.RealLocationSize = this.LocationSize;

            foreach (Control control in this.Controls)
                control.Redesign();            
        }


        /// <summary>
        /// Method Draw().
        /// </summary>
        public override void Draw()
        {
            ShevaEngine.Core.ShevaEngine.Instance.SpriteBatch.Begin();

            base.Draw();

            if (this.Cursor != null)
                this.Cursor.Draw();

            ShevaEngine.Core.ShevaEngine.Instance.SpriteBatch.End();
        }        
    }
}
